const { User } = require('../../model/user')
module.exports = async(req, res) => {
    req.app.locals.whatLink = 'user'
    let page = req.query.page || 1
    let usersCount = await User.countDocuments({})
    let pagesize = 2
    let total = Math.ceil(usersCount / pagesize)
    let start = (req.query.page - 1) * pagesize
    let allusers = await User.find({})
    let userLength = allusers.length
    let users = await User.find({}).limit(pagesize).skip(start)
    console.log(total)
    res.render('admin/user', {
        users: users,
        total: total,
        page: page,
        userLength: userLength
    })
}